package com.topdt.jbpm.model;

import java.io.UnsupportedEncodingException;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

/**
 * 
 * 建立日期 : 2013-7-19 上午08:48:49<br>
 * 作者 : 武海峰<br>
 * 模块 : <br>
 * 描述 : <br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
@Entity
@Table(name = "wf_flow_detail")
public class FlowDetail extends JbpmModel{
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "uuid")
	@Column(length = 32)
	private String detailId;
	
	private String flowId;
	private Date createTime;
	//是否已发布 "1"表示已发布  "0"表示草稿
	private String state;
	private String version;
	private String jbpmFlowId;
	private String jbpmFlowKey;
	
	@Lob
	private byte[] xml;// 二进制xml文件
	
	@Lob
	private byte[] json;// 二进制json内容

	@Transient
	private String gridClass;

	@Transient
	private int index;
	
	public String getDetailId() {
		return detailId;
	}

	public void setDetailId(String detailId) {
		this.detailId = detailId;
	}

	public String getFlowId() {
		return flowId;
	}

	public void setFlowId(String flowId) {
		this.flowId = flowId;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getJbpmFlowId() {
		return jbpmFlowId;
	}

	public void setJbpmFlowId(String jbpmFlowId) {
		this.jbpmFlowId = jbpmFlowId;
	}

	public String getJbpmFlowKey() {
		return jbpmFlowKey;
	}

	public void setJbpmFlowKey(String jbpmFlowKey) {
		this.jbpmFlowKey = jbpmFlowKey;
	}

	public byte[] getXml() {
		return xml;
	}
	
	public String getXmlStr() throws Exception{
		if(this.xml!=null){
			return new String(xml,"utf-8");
		}
		return null;
	}

	public void setXml(byte[] xml) {
		this.xml = xml;
	}

	public byte[] getJson() {
		return json;
	}
	
	public String getJsonStr(){
		if(this.json!=null){
			try {
				return new String(json,"utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

	public void setJson(byte[] json) {
		this.json = json;
	}

	public String getGridClass() {
		return gridClass;
	}

	public void setGridClass(String gridClass) {
		this.gridClass = gridClass;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}
	
}
